const KEY_PREFIX = 'PINIA_STORE_'

export default function(context) {
	const {
		store
	} = context;

	const KEY = KEY_PREFIX + store.$id.toUpperCase();
	
	// console.log('store', store)
	if(store.$id == 'runder') {
		return ;
	}
	
	//存
	store.$subscribe((mutation, state) => {
		uni.setStorage({
			key: KEY,
			data: state
		})
	})

	//读

	const localData = uni.getStorageSync(KEY)
	if (localData) store.$patch(localData)
}